<?php

if (strlen($this->data['username']) > 0) {
	$this->data['autofocus'] = 'password';
} else {
	$this->data['autofocus'] = 'username';
}
$this->includeAtTemplateBase('includes/header.php');

?>

<?php
if ($this->data['errorcode'] !== NULL) {
?>
	<div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5">
		<h2><?php echo $this->t('{login:error_header}'); ?></h2>
		<p><strong>Incorrect EUID or password</strong></p>
		<p>Either no user with the given EUID could be found, or the password you gave was wrong. Please check the EUID and try again.</p>
	</div>
<?php
}
?>
<!-- Show login panel -->
<div class="container">
    <div class="row">
        <div class="col-md-4 col-md-offset-4">
            <img src="/<?php echo $this->data['baseurlpath']; ?>resources/untsystemlogo.png" class="img-responsive center-block" style="padding: 20px 10px 20px 10px;">
            <div class="panel panel-default">
                <div class="panel-heading panel-title">Please Login</div>
                <div class="panel-body">
                	<form action="?" method="post" name="f">
                		<div class="form-group">
							<?php
							if ($this->data['forceUsername']) {
								echo '<strong style="font-size: medium">' . htmlspecialchars($this->data['username']) . '</strong>';
							} else {
								echo '<input type="text" class="form-control" placeholder="EUID" id="username" tabindex="1" name="username" value="' . htmlspecialchars($this->data['username']) . '" />';
							}
							?>
						</div>
						<div class="form-group">
							<input id="password" type="password" class="form-control" placeholder="Password" tabindex="2" name="password" />
						</div>
						<input type="submit" tabindex="5" class="btn btn-success" id="mobilesubmit" value="<?php echo $this->t('{login:login_button}'); ?>" />
						
						<?php
						foreach ($this->data['stateparams'] as $name => $value) {
							echo('<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />');
						}
						?>
					</form>
				</div>
				<div class="panel-footer">
                        <div class="text-center">
                            <p>Login using your EUID and password</p>
                        </div>
                    </div>

			</div>
		</div>
	</div>
</div>

<?php
if(!empty($this->data['links'])) {
	echo '<ul class="links" style="margin-top: 2em">';
	foreach($this->data['links'] AS $l) {
		echo '<li><a href="' . htmlspecialchars($l['href']) . '">' . htmlspecialchars($this->t($l['text'])) . '</a></li>';
	}
	echo '</ul>';
}
?>